"use strict";
/**
 * @name lockItem
 * 加锁&解锁/物品
 */

/**
 * @name lockItem
 * @param string key 物品唯一ID,用','分割。
 * 加锁物品
 */
exports.lockItem = async function () {
	const _key = this.get('key', 'string');
	if (!_key) {
		return this.quick_error('M2GHRPL1', '参数为空');
	}
	let reputation = _key.split(',');
	this.updater.role.key('lockItem');
	await this.updater.data();
	let _it = this.updater.role.get('lockItem') || {};
	for (let k in reputation) {
		_it[reputation[k]] = 1;
	}
	this.updater.role.set('lockItem', _it);
	return this.updater.save();
};


/**
 * @name unlockItem
 * @param string key 物品唯一ID,用','分割。
 * 解锁物品
 */
exports.unlockItem = async function () {
	const _key = this.get('key', 'string');
	if (!_key) {
		return this.quick_error('M2GHRPL11', '参数为空');
	}
	let reputation = _key.split(',');
	this.updater.role.key('lockItem');
	await this.updater.data();
	let _it = this.updater.role.get('lockItem') || {};
	for (let k in reputation) {
		delete _it[reputation[k]];
	}
	this.updater.role.set('lockItem', _it);
	return this.updater.save();
}; 